#define _CRT_SECURE_NO_WARNINGS
#include <iostream>

using namespace std;
typedef long long LL;
const int N = 300, M = 1e6 + 10;
LL n, m;
LL cnt[N], v[N];
LL sum;
LL f[M];
int main()
{
	cin >> n >> m;
	for (int i = 1; i <= n; i++) cin >> cnt[i];
	for (int i = 1; i <= n; i++)
	{
		cin >> v[i];
		sum += cnt[i] * v[i];
	}
	f[0] = 1;
	for (int i = 1; i <= n; i++)
	{
		for (int j = sum; j >= 0; j--)
		{
			for (int k = 0; k <= cnt[i] && k * v[i] <= j; k++)
			{
				f[j] = max(f[j], f[j - k * v[i]] * k);
			}
		}
	}
	for (int i = 1; i <= sum; i++)
	{
		if (f[i] >= m)
		{
			cout << i << endl;
			break;
		}
	}
	return 0;
}